/**
 * @param {number[]} nums
 * @return {number}
 */
var removeDuplicates = function (nums) {
  if (!nums.length) return 0
  let len = nums.length
  let left = 0
  let right = 1
  for (; right < len; right++) {
    if (nums[left] !== nums[right]) {
      left++
      nums[left] = nums[right]
    }
  }
  return left + 1
}
console.log(removeDuplicates([1, 1, 2]))
